package com.tim.app.ui.adapter.someone_homepage;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.application.library.net.StringResponseCallback;
import com.application.library.util.TimeUtil;
import com.application.library.widget.RatioImageView;
import com.application.library.widget.recycle.BaseRecyclerAdapter;
import com.application.library.widget.recycle.FlexibleDividerDecoration;
import com.application.library.widget.roundimg.RoundedImageView;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.tim.app.R;
import com.tim.app.constant.AppKey;
import com.tim.app.server.api.API_User;
import com.tim.app.server.entry.ActionStateMsg;
import com.tim.app.server.entry.Dynamic;
import com.tim.app.server.entry.Problem;
import com.tim.app.server.entry.User;
import com.tim.app.server.logic.UserManager;
import com.tim.app.server.result.ActionResult;
import com.tim.app.server.result.ResponseResult;
import com.tim.app.ui.activity.DynamicDetailActivity;
import com.tim.app.ui.activity.selected.QuestionAndAnswerDetailActivity;
import com.tim.app.ui.activity.some_homepage.SomeoneHomepageActivity;
import com.tim.app.ui.fragment.home.HomeDynamicFragment;
import com.tim.app.util.BitmapLoader;
import com.tim.app.util.ToastUtil;
import com.tim.app.util.ViewGT;

import java.util.List;

import jp.wasabeef.glide.transformations.BlurTransformation;


/**
 * 动态
 */
public class HomepageDynamicAdapter extends BaseRecyclerAdapter<BaseRecyclerAdapter.BaseRecyclerViewHolder, Dynamic> implements FlexibleDividerDecoration.VisibilityProvider {

    private Context mContext;

    static final int TYPE_STORY = 1;//故事
    static final int TYPE_ASK_QUESTION = 2;//问题
    static final int TYPE_ANSWER = 3;//回答
    static final int TYPE_ARTICLE = 4;//文章
    static final int TYPE_DYNAMIC = 5;//动态

    public HomepageDynamicAdapter(Context mContext, List<Dynamic> mDataList) {
        super(mDataList);
        this.mContext = mContext;
    }

    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseRecyclerViewHolder holder = null;
        switch (viewType) {
            case TYPE_STORY:
                holder = new StoryViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_dynamic_item_story, parent, false));
                break;
            case TYPE_ASK_QUESTION:
                holder = new QusetionViewHolder((LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_dynamic_item_ask_question, parent, false)));
                break;
            case TYPE_ANSWER:
                holder = new AnswerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_dynamic_item_answer, parent, false));
                break;
            case TYPE_ARTICLE:
                holder = new ArticleViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_dynamic_item_article, parent, false));
                break;
            case TYPE_DYNAMIC:
                holder = new DynamicViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_dynamic_item, parent, false));
                break;
        }
        return holder;
    }

    @Override
    public int getItemViewType(int position) {
        String type = getDataList().get(position).getDiscoverType();
        if (AppKey.TYPE_ARTICLE.equals(type)) {
            return TYPE_ARTICLE;
        } else if (AppKey.TYPE_ANSWER.equals(type)) {
            return TYPE_ANSWER;
        } else if (AppKey.TYPE_PROBLEM.equals(type)) {
            return TYPE_ASK_QUESTION;
        } else if (AppKey.TYPE_DYNAMIC.equals(type)) {
            return TYPE_DYNAMIC;
        } else if (AppKey.TYPE_STORY.equals(type)) {
            return TYPE_STORY;
        } else {
            return TYPE_ASK_QUESTION;
        }
    }

    @Override
    public boolean shouldHideDivider(int position, RecyclerView parent) {
        if (position == 0) {
            return true;
        }
        return false;
    }

    @Override
    public void onBindViewHolder(final BaseRecyclerViewHolder holder, int position, Dynamic data) {
        if (data == null) {
            return;
        }
        if (holder instanceof StoryViewHolder) {
            StoryViewHolder storyViewHolder = (StoryViewHolder) holder;
            updateStoryHolder(storyViewHolder, position, data);
        } else if (holder instanceof AnswerViewHolder) {
            AnswerViewHolder answerViewHolder = (AnswerViewHolder) holder;
            updateAnswerHolder(answerViewHolder, position, data);
        } else if (holder instanceof QusetionViewHolder) {
            QusetionViewHolder qusetionViewHolder = (QusetionViewHolder) holder;
            updateQuestionHolder(qusetionViewHolder, position, data);
        } else if (holder instanceof ArticleViewHolder) {
            ArticleViewHolder articleViewHolder = (ArticleViewHolder) holder;
            updateArticleHolder(articleViewHolder, position, data);
        } else if (holder instanceof DynamicViewHolder) {
            DynamicViewHolder dynamicViewHolder = (DynamicViewHolder) holder;
            updateDynamicHolder(dynamicViewHolder, position, data);
        }
    }

    /**
     * 更新动态UI
     *
     * @param holder
     * @param position
     * @param data
     */
    private void updateDynamicHolder(final DynamicViewHolder holder, final int position, final Dynamic data) {
        if (!TextUtils.isEmpty(data.getContent())) {
            holder.tvDynamicTitle.setVisibility(View.VISIBLE);
            holder.tvDynamicTitle.setText(data.getContent());
        } else {
            holder.tvDynamicTitle.setText("");
            holder.tvDynamicTitle.setVisibility(View.GONE);
        }
        if (null != data.getUserMsg()) {
            if (!TextUtils.isEmpty(data.getUserMsg().getName())) {
                holder.tvUserName.setText(data.getUserMsg().getName());
            } else {
                holder.tvUserName.setText("");
            }
            BitmapLoader.ins().loadImage(data.getUserMsg().getImage(), holder.rivAvatar);
            holder.rivAvatar.setTag(data.getUserMsg());
            holder.tvUserName.setTag(data.getUserMsg());

            holder.rivAvatar.setOnClickListener(onClickListener);
            holder.tvUserName.setOnClickListener(onClickListener);
        } else {
            holder.tvUserName.setText("");
            BitmapLoader.ins().loadImage("", holder.rivAvatar);
        }

        holder.tvPriseNumber.setText(mContext.getString(R.string.selectPriseNumber, String.valueOf(data.getAgreeCount())));
        holder.tvCommentNumber.setText(mContext.getString(R.string.selectCommentNumber, String.valueOf(data.getCommentCount())));
        holder.tvPublishTime.setText(TimeUtil.formatTimeRuleTwo(mContext, data.getCreateTime()) + mContext.getString(R.string.pointPrompt));

        if (null != data.getActionStateMsg()) {
            if (null != data.getActionStateMsg().getAgreeState()) {
                holder.ivPrise.setSelected(true);
            } else {
                holder.ivPrise.setSelected(false);
            }
        } else {
            holder.ivPrise.setSelected(false);
        }

        holder.ivPrise.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (!UserManager.ins().isLogin()) {
                    ViewGT.gotoLoginActivity(mContext);
                    return;
                }
                addPriseOrCancelPrise(holder.ivPrise, data, position);
            }
        });

        holder.ivComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DynamicDetailActivity.startWithShowKeyboard(mContext, data, true);
            }
        });

        if (null != data.getImageUrl()) {
            if (data.getImageUrl().size() == 0) {
                holder.rlImageContainer.setVisibility(View.GONE);
            } else {
                holder.rlImageContainer.setVisibility(View.VISIBLE);
                if (data.getImageUrl().size() == 1) {
                    holder.rivDynamicOne.setVisibility(View.VISIBLE);
                    holder.icContainerTwo.setVisibility(View.GONE);
                    holder.icContainerThree.setVisibility(View.GONE);
                    holder.icContainerFour.setVisibility(View.GONE);
                    holder.icContainerFive.setVisibility(View.GONE);
                    holder.icContainerSix.setVisibility(View.GONE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicOne);
                } else if (data.getImageUrl().size() == 2) {
                    holder.rivDynamicOne.setVisibility(View.GONE);
                    holder.icContainerTwo.setVisibility(View.VISIBLE);
                    holder.icContainerThree.setVisibility(View.GONE);
                    holder.icContainerFour.setVisibility(View.GONE);
                    holder.icContainerFive.setVisibility(View.GONE);
                    holder.icContainerSix.setVisibility(View.GONE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicTwo_one);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivDynamicTwo_two);
                } else if (data.getImageUrl().size() == 3) {
                    holder.rivDynamicOne.setVisibility(View.GONE);
                    holder.icContainerTwo.setVisibility(View.GONE);
                    holder.icContainerThree.setVisibility(View.VISIBLE);
                    holder.icContainerFour.setVisibility(View.GONE);
                    holder.icContainerFive.setVisibility(View.GONE);
                    holder.icContainerSix.setVisibility(View.GONE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicThree_one);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivDynamicThree_two);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(2), holder.rivDynamicThree_three);
                } else if (data.getImageUrl().size() == 4) {
                    holder.rivDynamicOne.setVisibility(View.GONE);
                    holder.icContainerTwo.setVisibility(View.GONE);
                    holder.icContainerThree.setVisibility(View.GONE);
                    holder.icContainerFour.setVisibility(View.VISIBLE);
                    holder.icContainerFive.setVisibility(View.GONE);
                    holder.icContainerSix.setVisibility(View.GONE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicFour_one);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivDynamicFour_two);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(2), holder.rivDynamicFour_three);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(3), holder.rivDynamicFour_four);
                } else if (data.getImageUrl().size() == 5) {
                    holder.rivDynamicOne.setVisibility(View.GONE);
                    holder.icContainerTwo.setVisibility(View.GONE);
                    holder.icContainerThree.setVisibility(View.GONE);
                    holder.icContainerFour.setVisibility(View.VISIBLE);
                    holder.icContainerFive.setVisibility(View.VISIBLE);
                    holder.icContainerSix.setVisibility(View.GONE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicFive_one);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivDynamicFive_two);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(2), holder.rivDynamicFive_three);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(3), holder.rivDynamicFive_four);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(4), holder.rivDynamicFive_five);
                } else if (data.getImageUrl().size() == 6) {
                    holder.rivDynamicOne.setVisibility(View.GONE);
                    holder.icContainerTwo.setVisibility(View.GONE);
                    holder.icContainerThree.setVisibility(View.GONE);
                    holder.icContainerFour.setVisibility(View.GONE);
                    holder.icContainerFive.setVisibility(View.GONE);
                    holder.icContainerSix.setVisibility(View.VISIBLE);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivDynamicSix_one);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivDynamicSix_two);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(2), holder.rivDynamicSix_three);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(3), holder.rivDynamicSix_four);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(4), holder.rivDynamicSix_five);
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(5), holder.rivDynamicSix_six);
                }
            }
        } else {
            holder.rlImageContainer.setVisibility(View.GONE);
        }
    }

    /**
     * 赞/取消赞
     */
    public void addPriseOrCancelPrise(final View view, final Dynamic dynamic, final int position) {
        view.setEnabled(false);
        if (null != dynamic.getActionStateMsg() && dynamic.getActionStateMsg().getAgreeState() != null) {
            int id = dynamic.getActionStateMsg().getAgreeState();
            API_User.ins().cancelPrise(HomeDynamicFragment.TAG, UserManager.ins().getUserId(), AppKey.TYPE_DYNAMIC, dynamic.getId(), AppKey.AGREE, id, dynamic.getUserMsg().getUserId(), new StringResponseCallback() {
                @Override
                public boolean onStringResponse(String resultValue, int errCode, String errMsg, int id, boolean formCache) {
                    view.setEnabled(true);
                    if (errCode == ResponseResult.ResultStatus.OK && resultValue != null) {
                        dynamic.setAgreeCount(dynamic.getAgreeCount() - 1);
                        dynamic.getActionStateMsg().setAgreeState(null);
                        getDataList().set(position, dynamic);
                        notifyItemChanged(position);
                    } else {
                        ToastUtil.showToast(errMsg);
                    }
                    return false;
                }
            });
        } else {
            API_User.ins().addPrise(HomeDynamicFragment.TAG, UserManager.ins().getUserId(), AppKey.TYPE_DYNAMIC, dynamic.getId(), AppKey.AGREE, dynamic.getUserMsg().getUserId(), new StringResponseCallback() {
                @Override
                public boolean onStringResponse(String resultValue, int errCode, String errMsg, int id, boolean formCache) {
                    view.setEnabled(true);
                    if (errCode == ResponseResult.ResultStatus.OK && resultValue != null) {
                        ActionResult result = new Gson().fromJson(resultValue, ActionResult.class);
                        if (null != result && null != result.getRes()) {
                            if (null == dynamic.getActionStateMsg()) {
                                dynamic.setActionStateMsg(new ActionStateMsg());
                            }
                            dynamic.getActionStateMsg().setAgreeState(result.getRes().getAction().getId());
                            dynamic.setAgreeCount(dynamic.getAgreeCount() + 1);
                            getDataList().set(position, dynamic);
                            notifyItemChanged(position);
                        }
                    } else {
                        ToastUtil.showToast(errMsg);
                    }
                    return false;
                }
            });
        }
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            User user = (User) v.getTag();
            if (null != user)
                SomeoneHomepageActivity.start(mContext, user, false);
        }
    };

    /**
     * 更新文章UI
     *
     * @param holder
     * @param position
     * @param data
     */
    private void updateArticleHolder(final ArticleViewHolder holder, int position, Dynamic data) {
        if (!TextUtils.isEmpty(data.getTitle())) {
            holder.tvArticleTitle.setText(data.getTitle());
        }
        if (!TextUtils.isEmpty(data.getContent())) {
            holder.tvArticleContent.setText(data.getContent());
        }
        if (null != data.getUserMsg()) {
            if (!TextUtils.isEmpty(data.getUserMsg().getName())) {
                holder.tvUserName.setText(data.getUserMsg().getName());
            }
            if (!TextUtils.isEmpty(data.getUserMsg().getImage())) {
                BitmapLoader.ins().loadImage(data.getUserMsg().getImage(), holder.rivAvatar);
            }
            holder.rivAvatar.setTag(data.getUserMsg());
            holder.tvUserName.setTag(data.getUserMsg());
            holder.rivAvatar.setOnClickListener(onClickListener);
            holder.tvUserName.setOnClickListener(onClickListener);
        }
        if (!TextUtils.isEmpty(data.getImage())) {
            holder.rivArticleCover.setVisibility(View.VISIBLE);
            BitmapLoader.ins().loadImage(data.getImage(), holder.rivArticleCover);
        } else {
            holder.rivArticleCover.setVisibility(View.GONE);
        }
        holder.tvPriseNumber.setText(mContext.getString(R.string.selectPriseNumber, String.valueOf(data.getAgreeCount())));
        holder.tvCommentNumber.setText(mContext.getString(R.string.selectCommentNumber, String.valueOf(data.getCommentCount())));
        holder.tvPublishTime.setText(TimeUtil.formatTimeRuleTwo(mContext, data.getCreateTime()) + mContext.getString(R.string.pointPrompt));
    }

    /**
     * 更新问题UI
     *
     * @param holder
     * @param position
     * @param data
     */
    private void updateQuestionHolder(final QusetionViewHolder holder, int position, Dynamic data) {
        if (null != data.getUserMsg()) {
            if (!TextUtils.isEmpty(data.getUserMsg().getName())) {
                holder.tvUserName.setText(data.getUserMsg().getName());
            }
            if (!TextUtils.isEmpty(data.getUserMsg().getImage())) {
                BitmapLoader.ins().loadImage(data.getUserMsg().getImage(), holder.rivAvatar);
            }
            holder.rivAvatar.setTag(data.getUserMsg());
            holder.tvUserName.setTag(data.getUserMsg());
            holder.rivAvatar.setOnClickListener(onClickListener);
            holder.tvUserName.setOnClickListener(onClickListener);
        }
        if (!TextUtils.isEmpty(data.getTitle())) {
            holder.tvQuestionTitle.setText(data.getTitle());
        }

        if (null != data.getImageUrl()) {
            holder.llImageContainer.setVisibility(View.VISIBLE);
            if (data.getImageUrl().size() == 1) {
                holder.llMoreImageContainer.setVisibility(View.GONE);
                holder.rivCover.setVisibility(View.VISIBLE);
                BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivCover);
            } else {
                holder.llMoreImageContainer.setVisibility(View.VISIBLE);
                holder.rivCover.setVisibility(View.GONE);
                BitmapLoader.ins().loadImage(data.getImageUrl().get(0), holder.rivCoverOne);
                if (data.getImageUrl().size() > 1) {
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(1), holder.rivCoverTwo);
                }
                if (data.getImageUrl().size() > 2) {
                    BitmapLoader.ins().loadImage(data.getImageUrl().get(2), holder.rivCoverThree);
                }
            }
        } else {
            holder.llImageContainer.setVisibility(View.GONE);
        }
        holder.tvFollowNumber.setText(mContext.getString(R.string.selectFollowNumber, String.valueOf(data.getConcernCount())));
        holder.tvAnswerNumber.setText(mContext.getString(R.string.selectAnswerNumber, String.valueOf(data.getAnswerCount())));
        holder.tvPublishTime.setText(TimeUtil.formatTimeRuleTwo(mContext, data.getCreateTime()) + mContext.getString(R.string.pointPrompt));
    }

    /**
     * 更新回答UI
     *
     * @param holder
     * @param position
     * @param data
     */
    private void updateAnswerHolder(final AnswerViewHolder holder, int position, final Dynamic data) {
        if (null != data.getUserMsg()) {
            if (!TextUtils.isEmpty(data.getUserMsg().getName())) {
                holder.tvUserName.setText(data.getUserMsg().getName());
            }
            if (!TextUtils.isEmpty(data.getUserMsg().getImage())) {
                BitmapLoader.ins().loadImage(data.getUserMsg().getImage(), holder.rivAvatar);
            }
            holder.rivAvatar.setTag(data.getUserMsg());
            holder.tvUserName.setTag(data.getUserMsg());
            holder.rivAvatar.setOnClickListener(onClickListener);
            holder.tvUserName.setOnClickListener(onClickListener);
        }
        holder.tvDynamicDesc.setText("回答了问题");
        if (!TextUtils.isEmpty(data.getProblemTitle())) {
            holder.tvQuestionTitle.setText(data.getProblemTitle());
        }
        if (!TextUtils.isEmpty(data.getContent())) {
            holder.tvQuestionContent.setText(data.getContent());
        }

        if (null != data.getImageUrl()) {
            List<String> dataImageUrl = data.getImageUrl();
            holder.llImageContainer.setVisibility(View.VISIBLE);
            if (data.getImageUrl().size() == 1) {
                holder.llMoreImageContainer.setVisibility(View.GONE);
                holder.rivCover.setVisibility(View.VISIBLE);
                BitmapLoader.ins().loadImage(dataImageUrl.get(0), holder.rivCover);
            } else {
                holder.llMoreImageContainer.setVisibility(View.VISIBLE);
                holder.rivCover.setVisibility(View.GONE);
                BitmapLoader.ins().loadImage(dataImageUrl.get(0), holder.rivCoverOne);
                if (dataImageUrl.size() > 1)
                    BitmapLoader.ins().loadImage(dataImageUrl.get(1), holder.rivCoverTwo);
                if (dataImageUrl.size() > 2)
                    BitmapLoader.ins().loadImage(dataImageUrl.get(2), holder.rivCoverThree);
            }
        } else {
            holder.llImageContainer.setVisibility(View.GONE);
        }

        holder.tvQuestionTitle.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Problem problem = new Problem();
                problem.setId(String.valueOf(data.getProblemId()));
                QuestionAndAnswerDetailActivity.start(mContext, problem, false);
            }
        });

        holder.tvPriseNumber.setText(mContext.getString(R.string.selectAnswerPriseNumber, String.valueOf(data.getAgreeCount())));
        holder.tvCommentNumber.setText(mContext.getString(R.string.selectCommentNumber, String.valueOf(data.getCommentCount())));
        holder.tvPublishTime.setText(TimeUtil.formatTimeRuleTwo(mContext, data.getCreateTime()) + mContext.getString(R.string.pointPrompt));
    }

    /**
     * 更新故事UI
     *
     * @param holder
     * @param position
     * @param data
     */
    private void updateStoryHolder(final StoryViewHolder holder, int position, Dynamic data) {
        if (null != data.getUserMsg()) {
            if (!TextUtils.isEmpty(data.getUserMsg().getName())) {
                holder.tvUserName.setText(data.getUserMsg().getName());
            } else {
                holder.tvUserName.setText("");
            }
            BitmapLoader.ins().loadImage(data.getUserMsg().getImage(), holder.rivAvatar);
            holder.tvUserName.setTag(data.getUserMsg());
            holder.rivAvatar.setTag(data.getUserMsg());
        } else {
            BitmapLoader.ins().loadImage("", holder.rivAvatar);
            holder.tvUserName.setText("");
            holder.tvUserName.setTag(null);
            holder.rivAvatar.setTag(null);
        }
        if (!TextUtils.isEmpty(data.getTitle())) {
            holder.tvStoryTitle.setText(data.getTitle());
        } else {
            holder.tvStoryTitle.setText("");
        }

        if (!TextUtils.isEmpty(data.getImage())) {
            BitmapLoader.ins().loadImage(data.getImage(), holder.rivStory);
            Glide.with(mContext)
                    .load(data.getImage())
                    .bitmapTransform(new BlurTransformation(mContext, AppKey.RADIUS))//高斯模糊
                    .into(holder.rivStoryBg);
        } else {
            BitmapLoader.ins().loadImage("", holder.rivStory);
        }
        holder.tvPriseNumber.setText(mContext.getString(R.string.selectPriseNumber, String.valueOf(data.getAgreeCount())));
        holder.tvCommentNumber.setText(mContext.getString(R.string.selectCommentNumber, String.valueOf(data.getCommentCount())));
        holder.tvPublishTime.setText(TimeUtil.formatTimeRuleTwo(mContext, data.getCreateTime()) + mContext.getString(R.string.pointPrompt));
    }

    /**
     * 故事
     */
    class StoryViewHolder extends BaseRecyclerViewHolder {

        RelativeLayout rlStory;
        RoundedImageView rivStoryBg;
        RoundedImageView rivStory;

        RoundedImageView rivAvatar;
        TextView tvUserName;
        TextView tvStoryTitle;
        TextView tvPriseNumber;
        TextView tvCommentNumber;
        TextView tvPublishTime;

        public StoryViewHolder(View itemView) {
            super(itemView);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            rlStory = (RelativeLayout) itemView.findViewById(R.id.rlStory);
            rivStoryBg = (RoundedImageView) itemView.findViewById(R.id.rivStoryBg);
            rivStory = (RoundedImageView) itemView.findViewById(R.id.rivStory);
            tvStoryTitle = (TextView) itemView.findViewById(R.id.tvStoryTitle);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            tvPriseNumber = (TextView) itemView.findViewById(R.id.tvPriseNumber);
            tvCommentNumber = (TextView) itemView.findViewById(R.id.tvCommentNumber);
            tvPublishTime = (TextView) itemView.findViewById(R.id.tvPublishTime);
        }

    }


    /**
     * 回答
     */
    class AnswerViewHolder extends BaseRecyclerViewHolder {

        RoundedImageView rivAvatar;
        TextView tvUserName, tvDynamicDesc;
        TextView tvQuestionTitle;
        TextView tvQuestionContent, tvPublishTime, tvPriseNumber, tvCommentNumber;
        LinearLayout llImageContainer;
        RatioImageView rivCover;
        LinearLayout llMoreImageContainer;
        RatioImageView rivCoverOne;
        RatioImageView rivCoverTwo;
        RatioImageView rivCoverThree;

        public AnswerViewHolder(View itemView) {
            super(itemView);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            tvDynamicDesc = (TextView) itemView.findViewById(R.id.tvDynamicDesc);
            tvQuestionTitle = (TextView) itemView.findViewById(R.id.tvQuestionTitle);
            tvQuestionContent = (TextView) itemView.findViewById(R.id.tvQuestionContent);
            tvPriseNumber = (TextView) itemView.findViewById(R.id.tvPriseNumber);
            tvCommentNumber = (TextView) itemView.findViewById(R.id.tvCommentNumber);
            tvPublishTime = (TextView) itemView.findViewById(R.id.tvPublishTime);
            llImageContainer = (LinearLayout) itemView.findViewById(R.id.llImageContainer);
            rivCover = (RatioImageView) itemView.findViewById(R.id.rivCover);
            llMoreImageContainer = (LinearLayout) itemView.findViewById(R.id.llMoreImageContainer);
            rivCoverOne = (RatioImageView) itemView.findViewById(R.id.rivCoverOne);
            rivCoverTwo = (RatioImageView) itemView.findViewById(R.id.rivCoverTwo);
            rivCoverThree = (RatioImageView) itemView.findViewById(R.id.rivCoverThree);
        }

    }

    /**
     * 问题
     */
    class QusetionViewHolder extends BaseRecyclerViewHolder {

        RoundedImageView rivAvatar;
        TextView tvUserName;
        TextView tvQuestionTitle;
        TextView tvPublishTime;
        TextView tvFollowNumber;
        TextView tvAnswerNumber;
        LinearLayout llImageContainer;
        RatioImageView rivCover;
        LinearLayout llMoreImageContainer;
        RatioImageView rivCoverOne;
        RatioImageView rivCoverTwo;
        RatioImageView rivCoverThree;

        public QusetionViewHolder(View itemView) {
            super(itemView);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            tvQuestionTitle = (TextView) itemView.findViewById(R.id.tvQuestionTitle);
            tvPublishTime = (TextView) itemView.findViewById(R.id.tvPublishTime);
            tvFollowNumber = (TextView) itemView.findViewById(R.id.tvFollowNumber);
            tvAnswerNumber = (TextView) itemView.findViewById(R.id.tvAnswerNumber);
            llImageContainer = (LinearLayout) itemView.findViewById(R.id.llImageContainer);
            rivCover = (RatioImageView) itemView.findViewById(R.id.rivCover);
            llMoreImageContainer = (LinearLayout) itemView.findViewById(R.id.llMoreImageContainer);
            rivCoverOne = (RatioImageView) itemView.findViewById(R.id.rivCoverOne);
            rivCoverTwo = (RatioImageView) itemView.findViewById(R.id.rivCoverTwo);
            rivCoverThree = (RatioImageView) itemView.findViewById(R.id.rivCoverThree);
        }

    }

    /**
     * 文章
     */
    class ArticleViewHolder extends BaseRecyclerViewHolder {

        RoundedImageView rivAvatar;
        TextView tvUserName;
        RatioImageView rivArticleCover;
        TextView tvArticleTitle, tvArticleContent, tvPriseNumber, tvCommentNumber, tvPublishTime;

        public ArticleViewHolder(View itemView) {
            super(itemView);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            rivArticleCover = (RatioImageView) itemView.findViewById(R.id.rivArticleCover);
            tvArticleTitle = (TextView) itemView.findViewById(R.id.tvArticleTitle);
            tvArticleContent = (TextView) itemView.findViewById(R.id.tvArticleContent);
            tvPriseNumber = (TextView) itemView.findViewById(R.id.tvPriseNumber);
            tvCommentNumber = (TextView) itemView.findViewById(R.id.tvCommentNumber);
            tvPublishTime = (TextView) itemView.findViewById(R.id.tvPublishTime);
        }

    }

    /**
     * 动态
     */
    class DynamicViewHolder extends BaseRecyclerViewHolder {

        RoundedImageView rivAvatar;
        TextView tvUserName;
        TextView tvDynamicTitle, tvPriseNumber, tvCommentNumber, tvPublishTime;

        RelativeLayout rlImageContainer;
        RatioImageView rivDynamicOne;

        View icContainerTwo;
        RatioImageView rivDynamicTwo_one;
        RatioImageView rivDynamicTwo_two;

        View icContainerThree;
        RatioImageView rivDynamicThree_one;
        RatioImageView rivDynamicThree_two;
        RatioImageView rivDynamicThree_three;

        View icContainerFour;
        RatioImageView rivDynamicFour_one;
        RatioImageView rivDynamicFour_two;
        RatioImageView rivDynamicFour_three;
        RatioImageView rivDynamicFour_four;

        View icContainerFive;
        RatioImageView rivDynamicFive_one;
        RatioImageView rivDynamicFive_two;
        RatioImageView rivDynamicFive_three;
        RatioImageView rivDynamicFive_four;
        RatioImageView rivDynamicFive_five;

        View icContainerSix;
        RatioImageView rivDynamicSix_one;
        RatioImageView rivDynamicSix_two;
        RatioImageView rivDynamicSix_three;
        RatioImageView rivDynamicSix_four;
        RatioImageView rivDynamicSix_five;
        RatioImageView rivDynamicSix_six;

        ImageView ivPrise;
        ImageView ivComment;

        public DynamicViewHolder(View itemView) {
            super(itemView);
            rivAvatar = (RoundedImageView) itemView.findViewById(R.id.rivAvatar);
            tvUserName = (TextView) itemView.findViewById(R.id.tvUserName);
            tvDynamicTitle = (TextView) itemView.findViewById(R.id.tvDynamicTitle);
            tvPriseNumber = (TextView) itemView.findViewById(R.id.tvPriseNumber);
            tvCommentNumber = (TextView) itemView.findViewById(R.id.tvCommentNumber);
            tvPublishTime = (TextView) itemView.findViewById(R.id.tvPublishTime);

            rlImageContainer = (RelativeLayout) itemView.findViewById(R.id.rlImageContainer);
            rivDynamicOne = (RatioImageView) itemView.findViewById(R.id.icContainerOne);

            icContainerTwo = itemView.findViewById(R.id.icContainerTwo);
            rivDynamicTwo_one = (RatioImageView) itemView.findViewById(R.id.rivDynamicTwo_one);
            rivDynamicTwo_two = (RatioImageView) itemView.findViewById(R.id.rivDynamicTwo_two);

            icContainerThree = itemView.findViewById(R.id.icContainerThree);
            rivDynamicThree_one = (RatioImageView) itemView.findViewById(R.id.rivDynamicThree_one);
            rivDynamicThree_two = (RatioImageView) itemView.findViewById(R.id.rivDynamicThree_two);
            rivDynamicThree_three = (RatioImageView) itemView.findViewById(R.id.rivDynamicThree_three);

            icContainerFour = itemView.findViewById(R.id.icContainerFour);
            rivDynamicFour_one = (RatioImageView) itemView.findViewById(R.id.rivDynamicFour_one);
            rivDynamicFour_two = (RatioImageView) itemView.findViewById(R.id.rivDynamicFour_two);
            rivDynamicFour_three = (RatioImageView) itemView.findViewById(R.id.rivDynamicFour_three);
            rivDynamicFour_four = (RatioImageView) itemView.findViewById(R.id.rivDynamicFour_four);

            icContainerFive = itemView.findViewById(R.id.icContainerFive);
            rivDynamicFive_one = (RatioImageView) itemView.findViewById(R.id.rivDynamicFive_one);
            rivDynamicFive_two = (RatioImageView) itemView.findViewById(R.id.rivDynamicFive_two);
            rivDynamicFive_three = (RatioImageView) itemView.findViewById(R.id.rivDynamicFive_three);
            rivDynamicFive_four = (RatioImageView) itemView.findViewById(R.id.rivDynamicFive_four);
            rivDynamicFive_five = (RatioImageView) itemView.findViewById(R.id.rivDynamicFive_five);

            icContainerSix = itemView.findViewById(R.id.icContainerSix);
            rivDynamicSix_one = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_one);
            rivDynamicSix_two = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_two);
            rivDynamicSix_three = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_three);
            rivDynamicSix_four = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_four);
            rivDynamicSix_five = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_five);
            rivDynamicSix_six = (RatioImageView) itemView.findViewById(R.id.rivDynamicSix_six);

            ivPrise = (ImageView) itemView.findViewById(R.id.ivPrise);
            ivComment = (ImageView) itemView.findViewById(R.id.ivComment);
        }

    }

}
